<?php defined('SYSPATH') OR die('No direct access allowed.');

class Default_Controller extends Base_Controller
{
	/**
	 * 默认页
	 */
	public function index($uri_segmnt='page',$page=1)
	{
		$this->template->head->title = 'ShareCode首页';
		$this->template->content = new View('index');
		$this->template->content->bind('list',$list);
		$this->template->content->bind('pagination',$pagination);

		$items_per_page = Kohana::config('pagination.default.items_per_page');
		$page = (int)$page;
		$page = $page<1?1:$page;
		$code = ORM::factory('code');
		$total_items = $code->count_all();
		$total_pages = floor(($total_items/$items_per_page)+1);
		$page = $page>$total_pages?$total_pages:$page;
		$list =$code->orderby('id','desc')->find_all($items_per_page,($page-1)*$items_per_page);

		$pagination = new Pagination(array(
			'base_url'		=>	'default/index',
			'total_items'	=>	$total_items,
			)
		);
	}
}
